#ifndef XNLOG_H
#define XNLOG_H

#include <QTimer>
#include <QDateTime>
#include <QObject>
#include <QLocalSocket>

// Message Log 1 - 100
#define MSG_TYPE_LOG_REGISTER             1   // 日志注册
#define MSG_TYPE_LOG_SELECT               2   // 日志帅选

typedef struct _SLogRegister
{
	int iProcess;         // 进程编码
	int iYear;            // 年
	int iMonth;           // 月
	int iDay;             // 日
	int iHour;            // 时
	int iMin;             // 分
	int iSec;             // 秒
}SLogRegister;

class CXnLog : public QObject
{
	Q_OBJECT

public:
	CXnLog(QObject *parent, int iProcess, QDateTime dtStart, const QString& strLogSrvName = "XnLogSrv");
	~CXnLog();

public:
	void startRemoteLog();
	void output2LogSrv(int iLogType, const QString& strLog);
	int getLogSelectType();

signals:
	void addLog(int iLogType, const QString& strLog);

private slots:
	void connect2Srv();
	void disconnected();	

private:
	int m_iProcess;
	QString m_strLogSrvName;

	QTimer* m_pTimer;
	QLocalSocket* m_pLocalSocket;
	bool m_bConnectedLogSrv;
	char* m_pBufferData;
	char* m_pCmdBufferData;
	QDateTime m_dtStart;

	int m_iLogSelectType;
};

#endif // XNLOG_H
